<?php

namespace App\Api\Controllers;

use App\Models\Car;
use Illuminate\Http\Request;

class CarsController extends Controller
{
    public function store(Car $car,Request $request){
        $id = $this->user()->id;
        $car->user_id = $id;
        $car->good_id = $request->input('good_id');
        $car->num = $request->input('num');
        $car->save();
        return $this->success('添加成功');
    }

    public function list(Car $car){
        $id = $this->user()->id;
        $res = $car->with('good')->where('user_id',$id)->orderBy('id','desc')->get();
        return $this->success($res);
    }
}
